package pers.liyan.shi.manager.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.liyan.shi.manager.client.NASClient;
import pers.liyan.shi.manager.common.Result;
import pers.liyan.shi.manager.configuration.NASProperties;
import pers.liyan.shi.manager.util.WOLUtils;

/**
 * @author ShiLY
 * @version 1.0
 * @date 2020/3/28 22:34
 */
@Api(tags = "NAS", description = "NAS管理")
@RequestMapping("/nas")
@RestController
public class NASController {

    @Autowired
    private NASProperties nasProperties;

    @Autowired
    private NASClient nasClient;

    @ApiOperation("WOL唤醒")
    @PostMapping("/wakeUp")
    public Result wakeUp() {

        WOLUtils.wakeUp(nasProperties.getIpAddr(), nasProperties.getMacAddr());

        return Result.ok();

    }

    @ApiOperation("关机")
    @PostMapping("/shutdown")
    public Result shutdown() {

        return nasClient.shutDown();

    }

    @ApiOperation("重启")
    @PostMapping("/restart")
    public Result restart() {

        return nasClient.restart();

    }

    @ApiOperation("撤销操作")
    @PostMapping("/cancel")
    public Result cancel() {

        return nasClient.cancel();

    }

}
